<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head th:include="admin/head :: head" th:with="title=权限管理编辑">
<body>
<div class="layuimini-container">
    <div class="layuimini-main">
        <form class="layui-form" action="" lay-filter="formfilter">
                <div class="layui-form-item">
                    <label class="layui-form-label"><span style="color: red">*</span>菜单:</label>
                    <div class="layui-input-block">
                        <select id="menuId" name="menuId" lay-verify="required">
                            <option th:each="t,tState:${ menuList}" th:value="${t.id}" th:text="${t.name}" th:selected="${t.id==m.menuId}"></option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label"><span style="color: red">*</span>权限名称:</label>
                    <div class="layui-input-block">
                            <input type="text" name="permissionName" lay-verify="required|permissionName" autocomplete="off"  class="layui-input" th:value="${ m.permissionName}">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label"><span style="color: red">*</span>按钮方法名称:</label>
                    <div class="layui-input-block">
                            <input type="text" name="methodName" lay-verify="required|methodName" autocomplete="off"  class="layui-input" th:value="${ m.methodName}">
                    </div>
                </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <input type="hidden" name="id" th:value="${ m.id}">
                    <button class="layui-btn" lay-submit="" lay-filter="formSubmit">立即提交</button>
                </div>
            </div>
        </form>
    </div>
</div>

<script>
    layui.use(['layedit', 'layer', 'jquery','liuQi'], function () {
            var form = layui.form,
                liuQi = layui.liuQi,
                laydate = layui.laydate;

            //日期
            form.render();

            //自定义验证规则
            form.verify({
                menuId: function (value) {
                },
                permissionName: function (value) {
                },
                methodName: function (value) {
                },
            });
        //监听提交
            form.on('submit(formSubmit)', function (data) {
                data=data.field;
                liuQi.ajax("/admin/permission/update",data,
                        function (data) {
                            //关闭
                            parent.layer.msg(data.msg);
                            parent.layui.table.reload('currentTableId');
                            var index = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(index);
                        }
                );
                return false;
            });
        });
</script>

</body>
</html>